package com.itls.recommendedgames.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;


public class Game {
    private Integer id;

    private String name;
    private String imageUrl;
    private String heroImageUrl;
    private String description;
    private BigDecimal price;
    private Byte discountPercent;
    private BigDecimal currentPrice;
    private BigDecimal rating;
    private LocalDateTime releasedAt;
    // 用于存储标签名
    private Set<String> tags = new HashSet<>();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getHeroImageUrl() {
        return heroImageUrl;
    }

    public void setHeroImageUrl(String heroImageUrl) {
        this.heroImageUrl = heroImageUrl;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Byte getDiscountPercent() {
        return discountPercent;
    }

    public void setDiscountPercent(Byte discountPercent) {
        this.discountPercent = discountPercent;
    }

    public BigDecimal getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(BigDecimal currentPrice) {
        this.currentPrice = currentPrice;
    }

    public BigDecimal getRating() {
        return rating;
    }

    public void setRating(BigDecimal rating) {
        this.rating = rating;
    }

    public LocalDateTime getReleasedAt() {
        return releasedAt;
    }

    public void setReleasedAt(LocalDateTime releasedAt) {
        this.releasedAt = releasedAt;
    }
    public void setTagsStr(String tagsStr) {
        if (tagsStr != null && !tagsStr.isEmpty()) {
            String[] tagArray = tagsStr.split(",");
            this.tags = new HashSet<>(Arrays.asList(tagArray));
        }
    }
    
    @JsonSerialize
    public Set<String> getTags() {
        return tags;
    }

    public void setTags(Set<String> tags) {
        this.tags = tags;
    }
    
    // 添加一个专门用于MyBatis映射的方法，避免方法重载冲突
    public void setTagsFromString(String tagsStr) {
        setTagsStr(tagsStr);
    }
}